<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Postservicio extends CI_Controller {
	
	public function __construct()
	{
		parent::__construct();
		$this->load->model('ws/postservicio_model');

	}
	public function index()
	{
		echo "Controlador para postservicio";
	}
	
	public function set_postServicioCampo(){
	
		$idAlerta=$this->input->post('idAlerta');
		$idUsuarioCampo=$this->input->post('idUsuarioCampo');
		$causas=$this->input->post('causas');
		$causado=$this->input->post('causado');
		$estructuras=$this->input->post('estructuras');
		
		$result=$this->postservicio_model->set_postServicioCampo($idAlerta, $idUsuarioCampo,$causas,$causado,$estructuras);
		$this->output->set_content_type('application/json')->set_output(json_encode($result));
	}
	
	public function get_acciones(){
		$idPostServicio=$this->input->post('idPostServicio');
		
		$result=$this->postservicio_model->get_acciones($idPostServicio);
		$this->output->set_content_type('application/json')->set_output(json_encode($result));
		
	}
	
	public function set_foto(){
		$image=$this->input->post('image');
		$idPostServicio=$this->input->post('idPostServicio');
		if (isset($idPostServicio)&& $idPostServicio!= ""){
			define('UPLOAD_DIR','./uploads/');
			$file = UPLOAD_DIR. "c_". $idPostServicio .'.jpg';
			$binary=base64_decode($image);
			$success = file_put_contents($file, $binary);
			if ($success){
				$this->postservicio_model->set_foto($idPostServicio,$file);
				$this->output->set_content_type('application/json')->set_output(json_encode($idPostServicio));
			}
		}
	}

		
}